import { Swiper, SwiperItem } from '@tarojs/components'
import styles from './index.module.scss'

interface SwipersProps {
  list: string[]
  width?: string
}
const Swipers: React.FC<SwipersProps> = ({ list, width }) => {
  const containerWidth = width ? width : '750px' // 使用 width 或者默认值 750px
  return (
    <div className={styles.swiper} style={{ width: containerWidth }}>
      <Swiper
        className={styles.swiper1}
        indicatorColor='#999'
        indicatorActiveColor='#333'
        circular
        indicatorDots={list?.length > 1 ? true : false}
        autoplay
      >
        {list?.length > 0 &&
          list.map((item) => (
            <SwiperItem key={item}>
              <img className={styles.img} src={item} alt='' />
            </SwiperItem>
          ))}
      </Swiper>
    </div>
  )
}

export default Swipers
